﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace Komunikator.Core
{
    class PasswordHash
    {
        public static byte[] GenerateHash(string password, int seed)
        {
            SHA1 sha1 = new SHA1CryptoServiceProvider();
            sha1.Initialize();
            byte[] passwordBytes = ASCIIEncoding.ASCII.GetBytes(password);
            byte[] seedBytes = BitConverter.GetBytes(seed);

            byte[] passAndSeed = new byte[passwordBytes.Length + seedBytes.Length];
            System.Buffer.BlockCopy(passwordBytes, 0, passAndSeed, 0, passwordBytes.Length);
            System.Buffer.BlockCopy(seedBytes, 0, passAndSeed, passwordBytes.Length, seedBytes.Length);

            byte[] hash = sha1.ComputeHash(passAndSeed);

            return hash;
            //throw new NotImplementedException();
        }
    }
}
